export const generateId = () => {
	return Math.floor(Math.random() * 100000 + Math.random() * 20000 + Math.random() * 5000)
}

export const randomString = (e: number) => {
	e = e || 32
	var t = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678',
		a = t.length,
		n = ''
	for (let i = 0; i < e; i++) n += t.charAt(Math.floor(Math.random() * a))
	return n
}

export const cloneWidget = (data) => {
	const newObj = JSON.parse(JSON.stringify(data))
	newObj.id = generateId()
	const propStr = randomString(6).toLowerCase()
	newObj.option.prop = propStr
	if (newObj.option.propName) {
		newObj.option.propName = propStr + 'Label'
	}
	return newObj
}
